VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsLineas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Dim vSQL As String

Public pNumError As Long
Public pDesError As String
Public pCanReg As Long
Public pRS As ADODB.Recordset
Public pIdDevuelto As Long

Private vIdLinea As Long

Public Property Let IdLinea(ByVal VData As Long)
    vIdLinea = VData
End Property
Public Property Get IdCliente() As Long
    IdLinea = vIdLinea
End Property

Private Sub AsignarValores(Optional ByVal rs As ADODB.Recordset, Optional pNoAsigRs As Boolean)
    If Not pNoAsigRs Then
        Set Me.pRS = rs
    End If
    Me.pCanReg = objCnxAeros.pCanReg
    Me.pDesError = objCnxAeros.pDesError
    Me.pIdDevuelto = objCnxAeros.pUltIdenOtor
    Me.pNumError = objCnxAeros.pNumError
End Sub


Public Function sel_Lineas(Optional ByVal nombreLinea)
Dim rs As New ADODB.Recordset
Dim strSQL As String

    If Not IsMissing(nombreLinea) Then
        strSQL = "SELECT a.id_linea,a.linea,a.id_lineaPad From lineas a WHERE a.fecha_baja is null " & _
        "a.linea like '%" & nombreLinea & "%' ORDER BY a.linea"
    Else
        strSQL = "SELECT a.id_linea,a.linea,a.id_lineaPad From lineas a WHERE a.fecha_baja is null " & _
        "ORDER BY a.Linea"
    End If
    
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    AsignarValores rs

End Function

Public Function ActualizarLinea_by_ID(ByVal id_Linea As Long, ByVal linea As String, _
                                      ByVal id_LineaPad As Long) As Boolean
Dim strSQL As String

    strSQL = " UPDATE lineas SET linea='" & linea & _
                                        "',id_LineaPad =" & id_LineaPad & _
                                        " WHERE lineas.id_linea =" & id_Linea
                                        
    If objCnxAeros.EjecutarComando(strSQL) Then
        ActualizarLinea_by_ID = True
    Else
        ActualizarLinea_by_ID = False
    End If

End Function

Public Function BorrarLinea_by_ID(ByVal id As Long)
Dim strSQL As String
    
    strSQL = " UPDATE lineas SET fecha_baja ='" & Date & "'" & _
             " WHERE lineas.id_linea =" & id

    If objCnxAeros.EjecutarComando(strSQL) Then
        BorrarLinea_by_ID = True
    Else
        BorrarLinea_by_ID = False
    End If

End Function

Public Function grabarLinea(ByVal linea As String, _
                               ByVal id_LineaPad As Long)
Dim strSQL As String
        
    
    strSQL = " INSERT INTO lineas (linea,id_LineaPad) values (" & _
                                        "'" & linea & _
                                        "'," & IIf(id_LineaPad = 0, "Null", id_LineaPad) & ")"
                                                                             
    If objCnxAeros.EjecutarComando(strSQL) Then
        grabarLinea = True
    Else
        grabarLinea = False
    End If

End Function

Public Function cargarLinea_by_ID(ByVal id As Long)
Dim rs As New ADODB.Recordset
Dim strSQL As String

   strSQL = "SELECT id_linea,linea,id_lineaPad From lineas WHERE " & _
        "id_linea =" & id
    
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    
    AsignarValores rs

End Function





